/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.eventos.bc;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.cip.esymons.eventos.be.DetalleMaterial;

/**
 *
 * @author Lizardo Rios
 */
public class DetalleMaterialDelegate {

    DetalleMaterialFacadeLocal local;

    public DetalleMaterialDelegate() {
        local = lookupDetallleMaterialFacade();
    }

    public void create(DetalleMaterial detalleMaterial) {
        local.create(detalleMaterial);
    }

    public void edit(DetalleMaterial detalleMaterial) {
        local.edit(detalleMaterial);
    }

    public void remove(DetalleMaterial detalleMaterial) {
        local.remove(detalleMaterial);
    }

    public DetalleMaterial find(Object id) {
        return local.find(id);
    }

    public List<DetalleMaterial> findAll() {
        return local.findAll();
    }

    public List<DetalleMaterial> listarDetalleXMaterial(Integer codigoMaterial) {
        return local.listarDetalleXMaterial(codigoMaterial);
    }

    private DetalleMaterialFacadeLocal lookupDetallleMaterialFacade() {
        try {
            Context c = new InitialContext();
            return (DetalleMaterialFacadeLocal) c.lookup("java:comp/env/DetallleMaterialFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }




}
